# coding=utf-8
# 全世界最帅的帅哥
from ysgg1_club_subject.comment.enums.subject_type_enum import SubjectTypeEnum
from ysgg1_club_subject.handler.subject.subject_type_handler import SubjectTypeHandler
from ysgg1_club_subject.handler.subject.radio_type_handler import RadioTypeHandler
from ysgg1_club_subject.handler.subject.multiple_type_handler import MultipleTypeHandler
from ysgg1_club_subject.handler.subject.judge_type_handler import JudgeTypeHandler
from ysgg1_club_subject.handler.subject.brief_type_handler import BriefTypeHandler


# 题目类型工厂
class SubjectTypeHandlerFactory:
    subject_type_handler_list = [RadioTypeHandler, MultipleTypeHandler, JudgeTypeHandler, BriefTypeHandler]
    handler_map = {}
    for subject_type_handler in subject_type_handler_list:
        handler_map[subject_type_handler.get_handler_type()] = subject_type_handler

    @classmethod
    def get_handler(cls, subject_type: int) -> SubjectTypeHandler:
        subject_type_enum = SubjectTypeEnum.get_by_code(subject_type)
        return cls.handler_map[subject_type_enum]
